// pages/person_info/person_info.js
const util = require("../../utils/util")
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
    avatar:'https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIVDBFq6eJxaSHoG5DiagPbrNFW0E0GZ9AtALjpZsrA6R1cVIibDNeBYJvzIvCvqHrlM0p5te7nmHIw/132',
    name: '炜烨烨烨烨',
      sex:[
        {name:'0',value:'男',checked:'true'},
        {name:'1',value:'女'}
      ],
      isSex:"0",
      location:["南校区","北校区"],
      value1: 0,
      phone: 18123456789
    },
    radioChange(e){
      console.log(e.detail.value);
      var sexName=this.data.isSex
      this.setData({
        isSex:e.detail.value
      })
    },
    pickerLocationChange(e) {
      this.setData({
        value: e.detail.value1,
      });
    },
    sendmess:function(e){
      wx.showLoading({
        title: '发布中',
        mask:'true'
      })
      wx.showToast({
        title: '提交成功！',
      })
    },
  
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        console.log('接收到的用户openid',options.openid)
        this.setData({
          userOpenid: options.openid
        })
    
    
        console.log(app.globalData.userInfo)
    
        var that = this;
        setTimeout(function(){
          console.log(app.globalData.openid)
          that.setData({
            myOpenid: app.globalData.openid
          })
        },2000)
        this.getInfo()
    },
    getInfo(){
        wx.cloud.database().collection('userInfo').where({
            _openid: this.data.userOpenid
          }).get({
            success(res){
              console.log(res)
              that.setData({
                avatar :res.data.avatar,
                name : res.data.name,
                phone : res.data.phone
              })
            }
          })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
    
    },
  
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
  
    },
  
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
      
  
  
  
         
    },
  
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
      
        
  
    
    },
  
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
    
    },
  
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
    
    },
  
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
    
    }
  })